using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DataObjects.ADO;

namespace WindowsFormsApplication1
{
    public partial class MainForm : DevComponents.DotNetBar.Metro.MetroForm
    {
        public static object _mainForm;
        public static SqlThamSo _ThamSo;        
        StartControl _startControl;

        #region Khai bao cac form
        public static LapTheDG _lapTheDG;
        public static NhapSach _nhapSach;        
        public static MuonSach _muonSach;
        public static CTSach _ctSach;
        public static ThuTienPhat _thuTienPhat;
        public static TraSach _traSach;
        public static TuyChinh _tuyChinh;
        public static ThongTinDocGia _formThongTinDG;

        form_Report_ThongKeMuon _reportMuonSach;
        form_Creport_TraTre _reportTraTre;        
        #endregion
        public MainForm()
        {        

            InitializeComponent();
            _mainForm = this;            
            this.SizeChanged += new EventHandler(MainForm_SizeChanged);

            _ThamSo = new SqlThamSo();

            _startControl = new StartControl();
            _startControl.titLapThDG.Click += new EventHandler(titLapThDG_Click);
            _startControl.titNhapSach.Click += new EventHandler(titNhapSach_Click);            
            _startControl.titMuonSach.Click += new EventHandler(titMuonSach_Click);
            _startControl.titChiTietSach.Click += new EventHandler(titChiTietSach_Click);
            _startControl.titThuTien.Click += new EventHandler(titThuTien_Click);
            _startControl.titTraSach.Click += new EventHandler(titTraSach_Click);
            _startControl.titOption.Click += new EventHandler(titOption_Click);
            _startControl.titBaoCaoTraTre.Click += new EventHandler(titBaoCaoTraTre_Click);
            _startControl.titThongTinDG.Click += new EventHandler(titThongTinDG_Click);
            _startControl.titBCMuonSach.Click += new EventHandler(titBCMuonSach_Click);

            _reportTraTre = new form_Creport_TraTre();
            this.Controls.Add(_reportTraTre);
            _reportTraTre.BringToFront();
            _reportTraTre.IsOpen = false;
            _reportTraTre.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Left;

            _formThongTinDG = new ThongTinDocGia();
            this.Controls.Add(_formThongTinDG);
            _formThongTinDG.BringToFront();
            _formThongTinDG.IsOpen = false;
            _formThongTinDG.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Right;

            _lapTheDG = new LapTheDG();            
            this.Controls.Add(_lapTheDG);
            _lapTheDG.BringToFront();            
            _lapTheDG.IsOpen = false;
            _lapTheDG.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Right;

            _nhapSach = new NhapSach();
            _nhapSach.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Left;
            this.Controls.Add(_nhapSach);
            _nhapSach.BringToFront();            
            _nhapSach.IsOpen = false;            

            _muonSach = new MuonSach();
            _muonSach.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Left;
            this.Controls.Add(_muonSach);
            _muonSach.BringToFront();
            _muonSach.IsOpen = false;

            _ctSach = new CTSach();
            _ctSach.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Right;
            this.Controls.Add(_ctSach);
            _ctSach.BringToFront();
            _ctSach.IsOpen = false;

            _thuTienPhat = new ThuTienPhat();
            _thuTienPhat.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Left;
            this.Controls.Add(_thuTienPhat);
            _thuTienPhat.BringToFront();
            _thuTienPhat.IsOpen = false;

            _traSach = new TraSach();
            _traSach.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Left;
            this.Controls.Add(_traSach);
            _traSach.BringToFront();
            _traSach.IsOpen = false;

            _reportMuonSach = new form_Report_ThongKeMuon();
            _reportMuonSach.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Left;
            this.Controls.Add(_reportMuonSach);
            _reportMuonSach.BringToFront();
            _reportMuonSach.IsOpen = false;

            this.Controls.Add(_startControl);
            UpdateStartControlLocation();
        }                
        
        private void MainForm_SizeChanged(object sender, EventArgs e)
        {
            UpdateStartControlLocation();        
        }        

        private void UpdateStartControlLocation()
        {
            _startControl.Location = new Point(
                this.Size.Width / 2 - _startControl.Size.Width / 2,
                this.Size.Height / 2 - _startControl.Size.Height / 2);
        }

        void titThongTinDG_Click(object sender, EventArgs e)
        {
            _formThongTinDG.UpdateSize();
            _formThongTinDG.ShowSlide();
        }

        void titBaoCaoTraTre_Click(object sender, EventArgs e)
        {
            _reportTraTre.UpdateSize();
            _reportTraTre.ShowSlide();
        }                     

        void titThuTien_Click(object sender, EventArgs e)
        {
            _thuTienPhat.UpdateSize();
            _thuTienPhat.ShowSlide();
        }        

        private void titLapThDG_Click(object sender, EventArgs e)
        {
            _lapTheDG.UpdateSize();
            _lapTheDG.ShowSlide();
        }

        private void titNhapSach_Click(object sender, EventArgs e)
        {
            _nhapSach.UpdateSize();
            _nhapSach.ShowSlide();
        }

        void titMuonSach_Click(object sender, EventArgs e)
        {
            _muonSach.UpdateSize();
            _muonSach.ShowSlide();
        }

        void titChiTietSach_Click(object sender, EventArgs e)
        {
            _ctSach.UpdateSize();
            _ctSach.ShowSlide();
        }

        void titTraSach_Click(object sender, EventArgs e)
        {
            _traSach.Update();
            _traSach.ShowSlide();
        }

        void titOption_Click(object sender, EventArgs e)
        {
            if (_tuyChinh == null)
            {
                _tuyChinh = new TuyChinh();                
            }
            _tuyChinh.Show();
        }

        void titBCMuonSach_Click(object sender, EventArgs e)
        {
            _reportMuonSach.UpdateSize();
            _reportMuonSach.ShowSlide();
        }        
    }
}